import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
// 引入mock数据
import "@/mock/mockServe";
Vue.config.productionTip = false;

// 引入swiper样式
import "swiper/css/swiper.css";

// 注册全局组件
import TypeNav from "@/components/TypeNav";
Vue.component("TypeNav", TypeNav);

import Carousel from "@/components/Carousel";
Vue.component(Carousel.name, Carousel);

import Pagination from "@/components/Pagination";
Vue.component(Pagination.name, Pagination);

// 导入全部api接口
import * as api from "@/api";

// 按需引入
/* 
import { Button, MessageBox } from "element-ui";
Vue.component(Button.name, Button);
// Vue.use(Button);

Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert; */
// 全部引入
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);

// 引入图片-默认对外暴露
import load from "@/assets/images/loading.gif";
import err from "@/assets/images/err.png";
// 图片懒加载
import VueLazyload from "vue-lazyload";
Vue.use(VueLazyload, {
	// 懒加载默认图片
	loading: load,
	error: err,
});

// 自定义插件
import myPlugin from "@/utils/MyPlugin";
Vue.use(myPlugin, {
	happy: "lalala",
});

new Vue({
	// 注册全局事件总线
	beforeMount() {
		Vue.prototype.$bus = this;
		Vue.prototype.$api = api;
	},
	router,
	store,
	render: (h) => h(App),
}).$mount("#app");
